home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / Add CF Parameter.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  5.0 KB  |  199 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. var CFParamNameList = null;
  4. var CFParamValue = null;
  5.  
  6.  
  7. // *************** GLOBALS VARS *****************
  8.  
  9. var HELP_DOC = MM.HELP_cmdCFAddParam; 
  10.  
  11.  
  12. //*************************API**************************
  13.  
  14. //--------------------------------------------------------------------
  15. // FUNCTION:
  16. //   commandButtons
  17. //
  18. // DESCRIPTION:
  19. //   Returns the array of buttons that should be displayed on the
  20. //   right hand side of the dialog.  The array is comprised
  21. //   of name, handler function name pairs.
  22. //
  23. // ARGUMENTS:
  24. //   none
  25. //
  26. // RETURNS:
  27. //   array of strings - name, handler function name pairs
  28. //--------------------------------------------------------------------
  29.  
  30. function commandButtons()
  31. {                          
  32.   return new Array(MM.BTN_OK,     "okClicked()",
  33.                    MM.BTN_Cancel, "cancelClicked()",
  34.                    MM.BTN_Help,   "displayHelp()" );
  35. }
  36.  
  37.  
  38. //--------------------------------------------------------------------
  39. // FUNCTION:
  40. //   okClicked
  41. //
  42. // DESCRIPTION:
  43. //   Sets the return value to the selected DSN and closes the window.
  44. //
  45. // ARGUMENTS:
  46. //   none
  47. //
  48. // RETURNS:
  49. //   nothing
  50. //--------------------------------------------------------------------
  51.  
  52. function okClicked()
  53. {
  54.   var paramName = CFParamNameList.get();
  55.   var paramDefault = CFParamValue.value;
  56.   if (!paramName || !dwscripts.trim(paramName))
  57.   {
  58.     alert(MM.MSG_MissingParameterName); 
  59.   }
  60.   else
  61.   {
  62.     var retArray = new Array(paramName,paramDefault); 
  63.     dwscripts.setCommandReturnValue(retArray);
  64.     window.close();
  65.   } 
  66. }
  67.  
  68. //--------------------------------------------------------------------
  69. // FUNCTION:
  70. //   cancelClicked
  71. //
  72. // DESCRIPTION:
  73. //   Closes the window and returns nothing
  74. //
  75. // ARGUMENTS:
  76. //   none
  77. //
  78. // RETURNS:
  79. //   nothing
  80. //--------------------------------------------------------------------
  81.  
  82. function cancelClicked()
  83. {
  84.   dwscripts.setCommandReturnValue("");
  85.  
  86.   window.close();
  87. }
  88.  
  89. //--------------------------------------------------------------------
  90. // FUNCTION:
  91. //   displayHelp
  92. //
  93. // DESCRIPTION:
  94. //   This function is called when the user clicks the HELP button
  95. //
  96. // ARGUMENTS:
  97. //   none
  98. //
  99. // RETURNS:
  100. //   nothing
  101. //--------------------------------------------------------------------
  102.  
  103. function displayHelp()
  104. {
  105.   dwscripts.displayDWHelp(HELP_DOC);
  106. }
  107.  
  108. // ***************** LOCAL FUNCTIONS  ******************
  109. //--------------------------------------------------------------------
  110. // FUNCTION:
  111. //   updateUI
  112. //
  113. // DESCRIPTION:
  114. //   This function is called by the UI controls to handle UI updates
  115. //
  116. // ARGUMENTS:
  117. //   control - string - the name of the control sending the event
  118. //   event - string - the event which is being sent
  119. //
  120. // RETURNS:
  121. //   nothing
  122. //--------------------------------------------------------------------
  123.  
  124. function updateUI(control, event)
  125. {
  126.   if (control == "CFParamName")
  127.   {
  128.     CFParamValue.value = "";
  129.   }
  130. }
  131.  
  132.  
  133. //--------------------------------------------------------------------
  134. // FUNCTION:
  135. //   initializeUI
  136. //
  137. // DESCRIPTION:
  138. //   This function is called in the onLoad event.  It is responsible
  139. //   for initializing the UI.  If we are inserting a recordset, this
  140. //   is a matter of populating the connection drop down.
  141. //
  142. //   If we are modifying a recordset, this is a matter of inspecting
  143. //   the recordset tag and setting all the form elements.
  144. //
  145. // ARGUMENTS:
  146. //   none
  147. //
  148. // RETURNS:
  149. //   nothing
  150. //--------------------------------------------------------------------
  151.  
  152. function initializeUI()
  153. {
  154.   var theArgumentObj = dwscripts.getCommandArguments(); 
  155.  
  156.   var isEdit = false;
  157.   var nameList = new Array();
  158.   var selectName = "";
  159.   var selectDefault = ""; 
  160.   
  161.   if (theArgumentObj && theArgumentObj.length) 
  162.   {
  163.     isEdit = (theArgumentObj[0]) ? theArgumentObj[0] : false;
  164.     nameList = (theArgumentObj[1]) ? theArgumentObj[1] : new Array();
  165.     selectName = (theArgumentObj[2]) ? theArgumentObj[2] : "";
  166.     selectDefault = (theArgumentObj[3]) ? theArgumentObj[3] : ""; 
  167.   }
  168.  
  169.   CFParamNameList = new ListControl("CFParamName"); 
  170.   CFParamNameList.setAll(nameList, nameList);
  171.   if (nameList.length)
  172.   {
  173.     CFParamNameList.setIndex(0);
  174.   }
  175.   else
  176.   {
  177.     CFParamNameList.setIndex(-1);
  178.     
  179.     // Bug: when bring up dialog for second time, the param name list remembers
  180.     //   the last value that was selected - even if you setAll with a blank array. 
  181.     //   I assume this has to do with the fact that this is an editable select
  182.     //   list. This workaround ensures the beginning value is empty.
  183.     CFParamNameList.pick("");
  184.   }
  185.   
  186.   CFParamValue = dwscripts.findDOMObject("CFParamValue"); 
  187.   CFParamValue.value = selectDefault; 
  188.   if (isEdit)
  189.   {
  190.     CFParamNameList.pick(selectName);
  191.     CFParamNameList.disable();
  192.     CFParamValue.focus();
  193.   }
  194.   else
  195.   {
  196.     CFParamNameList.enable();
  197.     CFParamNameList.focus()
  198.   }
  199. }